#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>

int main(int argc,char** argv)
{
  pid_t pid,wpid;
  for(int i = 0;i < 5;i++)
  {
    usleep(i*1000);
    pid = fork();
    if(pid == 0)
    {
      printf("I am %d child,my pid is %d\n",i,getpid());
      return 1;
    }
  }

  while((wpid = waitpid(-1,NULL,0)) != -1)
  {
    printf("waitpid is %d\n",wpid);
  }

  return 0;
}
